'''
Created on Mar 17, 2016

@author: grind
'''

tel = {'jack': 4098, 'sape': 4139}
print(tel)

tel['guido'] = 4127
print(tel)

print(tel['jack'])

del(tel['sape'])

print(tel)

keys = list(tel.keys())
print(keys)
print(sorted(keys))

tel2 = dict([('sape', 4139), ('guido', 4127), ('jack', 4098)])
print(tel2)

print('-'*50)
# 字典推导式
a = {x: x**2 for x in (2, 4, 6)}
print(a)

# 循环技巧
knights = {'gallahad': 'the pure', 'robin': 'the brave'}
for k, v in knights.items():
    print(k,':', v)

dictyear={'2015': 160, '2010': 129, '2012': 240, '2014': 235, '2013': 238, '2016': 76, '2011': 241}
sortedYears=sorted(dictyear.keys())
print(sortedYears)
for year in sortedYears :
    if int(year) >= 2013:
        print(year)
